Page({
  onReady: function (e) {
    // 使用 wx.createMapContext 获取 map 上下文
    this.mapCtx = wx.createMapContext('myMap')
    this.mapCtx.moveToLocation()
  },
  getCenterLocation: function () {
    this.mapCtx.getCenterLocation({
      success: function (res) {
        console.log(res)
        console.log(res.longitude)
        console.log(res.latitude)
      }
    })
  },
  moveToLocation: function () {
    this.mapCtx.moveToLocation()
  },
  translateMarker: function () {
    this.mapCtx.translateMarker({
      markerId: 0,
      autoRotate: true,
      duration: 1000,
      destination: {
        latitude: 23.10229,
        longitude: 113.3345211,
      },
      animationEnd() {
        console.log('animation end')
      }
    })
  },
  includePoints: function () {
    this.mapCtx.includePoints({
      padding: [10],
      points: [{
        latitude: 23.10229,
        longitude: 113.3345211,
      }, {
        latitude: 23.00229,
        longitude: 113.3345211,
      }]
    })
  },
  search:function(){
    wx.scanCode({
      success: (res) => {
        wx.navigateTo({
          url: res.result,
          success: function(res) {},
          fail: function(res) {},
          complete: function(res) {},
        })
        console.log(res)
      }
    })    
  },
  getAddresss:function(){
    wx.getLocation({
      type: 'wgs84',
      success: function (res) {
        var latitude = res.latitude
        var longitude = res.longitude
        var speed = res.speed
        var accuracy = res.accuracy

        console.log(res);
        
      },
      fail: function (res) {
        console.log(res);
      }
    })
  },
  chooseLocation:function(){
    wx.chooseLocation({
      success:function(res){
        console.log(res.latitude);
        console.log(res.longitude);
        console.log(res.name);
        console.log(res.address);
      }
    })
  }
})